package com.yiidata.rpc.rmi;

import com.yiidata.rpc.hrpc.User;

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.ObjectOutputStream;
import java.util.HashMap;
import java.util.Map;

/**
 * <pre>
 *
 * Created by zhenqin.
 * User: zhenqin
 * Date: 2018/1/6
 * Time: 14:47
 * Verdor: NowledgeData
 * To change this template use File | Settings | File Templates.
 *
 * </pre>
 *
 * @author zhenqin
 */
public class SerializableObjectToBytes {


    public static void main(String[] args) throws Exception {
        Map<String, String> param = new HashMap<>();
        param.put("message", "HadoopRPC, User Instance.");
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ObjectOutputStream outputStream = new ObjectOutputStream(out);
        outputStream.writeObject(param);
        outputStream.flush();
        outputStream.close();

        byte[] bytes = out.toByteArray();
        System.out.println(bytes.length);
    }
}
